package com.yuxl.ai.knowledgeText.controller;

import com.yuxl.ai.knowledgeText.domain.AiKnowledgeTextEmbeddingQuery;
import com.yuxl.ai.knowledgeText.domain.AiKnowledgeTextEmbeddingRes;
import com.yuxl.ai.knowledgeText.entity.AiKnowledgeTextEmbedding;
import com.yuxl.ai.knowledgeText.service.AiKnowledgeTextEmbeddingService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

import java.util.List;

/**
 * @Author : yuxl
 * @create 2025/7/11 上午9:45
 */
@Tag(name = "文本知识库:向量化")
@RequestMapping("/ai/knowledgeTextEmbedding")
@RestController
public class AiKnowledgeTextEmbeddingController {

    @Resource
    private AiKnowledgeTextEmbeddingService aiKnowledgeTextEmbeddingService;

    @Operation(summary = "向量化")
    @PostMapping("/{id}")
    public Flux<AiKnowledgeTextEmbedding> embedding(@Parameter(description = "文本知识库ID") @PathVariable Long id) {
        return aiKnowledgeTextEmbeddingService.embedding(id);
    }

    @Operation(summary = "查询")
    @PostMapping("/query")
    public Mono<List<AiKnowledgeTextEmbeddingRes>> query(@RequestBody AiKnowledgeTextEmbeddingQuery entity) {
        return aiKnowledgeTextEmbeddingService.query(entity);
    }
}
